require.config({
//	baseUrl: 'js', // Base URL is /js anyway, that is inherited from the index.html, data-main attribute.
	paths: {
		jquery: 'lib/jquery',
		jqueryui: 'lib/jquery-ui',
		underscore: 'lib/underscore',
		backbone: 'lib/backbone',
		text: 'lib/text'
//		book: 'model/book', 
//		library: 'model/library', 
//		bookView: 'view/bookview',
//		libraryView: 'view/library',
//		libraryApp: 'view/appview'
// Do not define patch to application specific files, use full path in require call
	},
	shim: {
		'underscore': {
			exports: '_'
		},
		'jquery': {
			exports: '$'
		},
		'jqueryui': {
			deps:['jquery']
		},
		'backbone': {
			deps: ['underscore','jquery'],
			exports: 'Backbone'
		}
	}
});

var appCTX = {};

//require( ['underscore','jquery','backbone', '../model/book', '../view/bookview' ], function(_,$,Backbone, Book, BookView) {
require( ['underscore', 'jquery', 'backbone', 'view/appview', 'library_router', 'jqueryui' ], function( _, $, Backbone, LibraryApp, LibraryRouter) {

	/* <<<
	var book = new Book({
							title:"Some title",
							author:"John Doe",
							releaseDate:"2012",
							keywords:"JavaScript Programming"
						});

	var bookView = new BookView({
							model:book
						});

	$("#books").html(bookView.render().el);
	
	// jQuery UI initialize a toolbar

	$( "#beginning" ).button({
		text: false,
		icons: {
			primary: "ui-icon-seek-start"
		}
	});

	$( "#rewind" ).button({
		text: false,
		icons: {
			primary: "ui-icon-seek-prev"
		}
	});

	$( "#play" ).button({
		text: false,
		icons: {
			primary: "ui-icon-play"
		}
	}).click(function() {
		var options;
		if ( $( this ).text() === "play" ) {
			options = {
				label: "pause",
				icons: {
					primary: "ui-icon-pause"
				}
			};
		} else {
			options = {
				label: "play",
				icons: {
 	  				primary: "ui-icon-play"
				}
			};
		}

 	  	$(this).button( "option", options );
	});

	$( "#stop" ).button({
		text: false,
		icons: {
			primary: "ui-icon-stop"
		}
	}).click(function() {
		$( "#play" ).button( "option", {
			label: "play",
			icons: {
				primary: "ui-icon-play"
			}
		});
	});

	$( "#forward" ).button({
		text: false,
		icons: {
			primary: "ui-icon-seek-next"
		}
	});

	$( "#end" ).button({
		text: false,
		icons: {
  	 		primary: "ui-icon-seek-end"
		}
	});

	$( "#shuffle" ).button();
	$( "#repeat" ).buttonset();
	
	*/
	// >>>

	appCTX = _.extend( appCTX, Backbone.Events );
	/* Global object for message pumping across the application.
	 * The pattern "ListenTo" allows to register events originating
	 * in other objects, which is a very useful pattern in this app.
	 */

	//$("#mainViewAccordion").accordion();
	$("a,button").button();
	$("#releaseDate").datepicker();
	/* This can be a possible place to put the UI widgets from jQuery UI.
	 * Don't really know if I want to put it here, the best way might
	 * be actually the View ...
	 */

    //$("#menu").menu();
	 $("#add-book-form-id").button();
	 $("#show-library-id").button();
	
	 $( "#viewMode" ).buttonset();

	var libraryRouter = new LibraryRouter();
	var libraryApp = new LibraryApp();

	Backbone.history.start();
});

